using Provausio.Common.Objects;
using TrainingManagement.api.Models.BusinessObjects.Responses;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.SkillSet;

namespace TrainingManagement.api.Models.BusinessLogic.SkillSet
{
    public class SkillSetUpdateOperation : BusinessOperation<BusinessObjects.SkillSet, GeneralResponse>
    {
        readonly SkillSetUpdateDataSource _skillSetUpdate = new SkillSetUpdateDataSource();

        public override GeneralResponse Run(BusinessObjects.SkillSet input)
        {
            var resp = new GeneralResponse();
            if (_skillSetUpdate.Execute(input))
            {
                resp.Message = string.Format("\"{0}\" was updated successfully!", input.Title);
                resp.StatusCode = 200;
                return resp;
            }

            resp.Message = string.Format("\"{0}\" was not updated!", input.Title);
            resp.StatusCode = 500;
            return resp;
        }
    }
}